<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <ui:composition >
    
        <p:panel id="addresspanel" header="Addresses">
            <h:panelGroup >
                <p:dataTable id="addresslist" value="#{vendorEntityController.selectedVendor.contact.addresses}"  
                             var="address" paginator="true" rows="10" widgetVar="addresstable" 
                             selection="#{addressEntityController.current}" selectionMode="single"  
                             onRowSelectUpdate="display" onRowSelectComplete="carDialog.show()"> 

                    <p:column >  

                        <h:outputText value="#{address.type}" />
                        <br />

                        <h:outputText value="#{address.streetAddress}" title="#{bundle.CreateAddressEntityTitle_streetAddress}" />
                        <br />

                        <h:outputText value="#{address.city}" title="#{bundle.CreateAddressEntityTitle_city}" />                
                        <h:outputText value=", " />
                        <h:outputText value="#{address.stateOrProvice}" title="#{bundle.CreateAddressEntityTitle_stateOrProvice}" />
                        <br />

                        <h:outputText value="#{address.country}" title="#{bundle.CreateAddressEntityTitle_country}" />
                        <h:outputText value=", " />
                        <h:outputText value="#{address.zipCode}" title="#{bundle.CreateAddressEntityTitle_zipCode}" />
                        <br />

                    </p:column>
                </p:dataTable>
                <br />
                <p:commandLink id="newaddresslink" value="Add Address" action="#{addressEntityController.prepareNewAddress}" update="display" onsuccess="carDialog.show();" onstart="addresstable.clearSelection();"/>
 
                <p:dialog header="Edit Address" widgetVar="carDialog" resizable="false"  
                          width="300" showEffect="explode" hideEffect="explode">  

                    <h:panelGrid id="display" columns="2" >
                        <h:outputLabel value="Type: " for="type" />
                        <h:selectOneMenu id="type" value="#{vendorEntityController.selectedA.type}"  >
                            <f:selectItems value="#{addressEntityController.addressTypes}" />
                        </h:selectOneMenu>

                        <h:outputLabel value="#{bundle.CreateAddressEntityLabel_streetAddress}" for="streetAddress" />
                        <h:inputText id="streetAddress" value="#{vendorEntityController.selectedA.streetAddress}" title="#{bundle.CreateAddressEntityTitle_streetAddress}" />    

                        <h:outputLabel value="#{bundle.CreateAddressEntityLabel_city}" for="city" />
                        <h:inputText id="city" value="#{vendorEntityController.selectedA.city}" title="#{bundle.CreateAddressEntityTitle_city}" />

                        <h:outputLabel value="#{bundle.CreateAddressEntityLabel_stateOrProvice}" for="stateOrProvice" />
                        <h:inputText id="stateOrProvice" value="#{vendorEntityController.selectedA.stateOrProvice}" title="#{bundle.CreateAddressEntityTitle_stateOrProvice}" />

                        <h:outputLabel value="#{bundle.CreateAddressEntityLabel_country}" for="country" />
                        <h:inputText id="country" value="#{vendorEntityController.selectedA.country}" title="#{bundle.CreateAddressEntityTitle_country}" />

                        <h:outputLabel value="#{bundle.CreateAddressEntityLabel_zipCode}" for="zipCode" />
                        <h:inputText id="zipCode" value="#{vendorEntityController.selectedA.zipCode}" title="#{bundle.CreateAddressEntityTitle_zipCode}" />

                        <h:outputText value=" " />
                        <p:commandButton action="#{vendorEntityController.updateAddress}" value="Save" update="addresslist" oncomplete="carDialog.hide();"/>
                    </h:panelGrid>

                </p:dialog> 

            </h:panelGroup>
        </p:panel>
    </ui:composition>

</html>
